package com.breakfast.fun.util;

import android.app.Activity;
import android.graphics.drawable.BitmapDrawable;
import android.view.WindowManager;
import android.widget.PopupWindow;

import com.breakfast.fun.R;


/**
 * popwindow弹出管理器
 * Created by Administrator on 2016/8/12.
 */
public class PopUtil {

    public static void setPop(PopupWindow popupWindow) {
        //在PopupWindow里面就加上下面代码，让键盘弹出时，不会挡住pop窗口。
        popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        //点击空白处时，隐藏掉pop窗口
        popupWindow.setFocusable(true);
        popupWindow.setOutsideTouchable(true);
        popupWindow.setBackgroundDrawable(new BitmapDrawable());
        popupWindow.setAnimationStyle(R.style.app_pop);// 动画效果
    }

    public void backgroundAlpha(Activity activity, float bgAlpha) {
        WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
        lp.alpha = bgAlpha; //0.0-1.0
        activity.getWindow().setAttributes(lp);
    }
}
